import { IUser } from '@src/types/account';
import { createSlice } from '@reduxjs/toolkit';

// user的slice
export const userSlice = createSlice({
  name: 'test',
  initialState: {} as IUser,
  reducers: {
    setUserInfo: (state, action) => {
      state = action.payload;
      return state;
    },
  },
});

// 获取action
export const updateUserInfo =
  (key: keyof typeof userSlice.actions) => (payload: any) =>
    userSlice.actions[key](payload);

export const { actions: userActions, reducer: userReducer } = userSlice;
